<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用Axios传值Restful风格</title>
    <script src="vue.js"></script>
    <script src="axios.min.js"></script>
    
</head>

<body>
    <div id="app">
       <input type="text" v-model="uid" placeholder="请输入用户编号">
       <button @click="getUserById()">查询</button><br>
        电话：{{user.telephone}}<br>
        密码：{{user.password}}
    </div>


</body>

</html>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            uid:"",
            // url:`http://localhost:8080/users/${this.uid}`,
            user:{}
        },
        methods: {
            //获取用户信息
            getUserById() {
                var url=`http://localhost:8080/users/${this.uid}`;
               axios.get(url).then(res=>{
                   this.user=res.data.data.user;
               })
            }
        },
    })
</script>